package com.hjxr.sysadmin.zsj.controller;

import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;
import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.controller.BaseController;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import com.hjxr.sysadmin.zsj.domain.ZIndustry;
import com.hjxr.sysadmin.zsj.domain.Zone;
import com.hjxr.sysadmin.zsj.service.IZoneService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 地块属性信息Controller
 *
 * @date 2021-03-10
 */
@Api("地块属性信息")
@RestController
@RequestMapping("/zone")
public class ZoneController extends BaseController {
	@Autowired
	private IZoneService zoneService;

	/**
	 * 查询地块属性信息列表
	 */
	@ApiOperation("查询地块属性信息列表")
	@GetMapping("/list")
	public TableDataInfo list(Zone zone) {
		startPage();
		List<Zone> list = zoneService.selectZoneList(zone);
		return getDataTable(list);
	}

	/**
	 * 导出地块属性信息列表
	 */
	@ApiOperation("导出地块属性信息列表")
	@Log(title = "地块属性信息", businessType = BusinessType.EXPORT)
	@GetMapping("/export")
	public AjaxResult export(Zone zone) {
		List<Zone> list = zoneService.selectZoneList(zone);
		ExcelUtil<Zone> util = new ExcelUtil<Zone>(Zone.class);
		return util.exportExcel(list, "zone");
	}

	/**
	 * 获取地块属性信息详细信息
	 */
	@ApiOperation("获取地块属性信息详细信息")
	@GetMapping(value = "/{zoneId}")
	public AjaxResult getInfo(@PathVariable("zoneId") Long zoneId) {
		return AjaxResult.success(zoneService.selectZoneById(zoneId));
	}

	/**
	 * 新增地块属性信息
	 */
	@ApiOperation("新增地块属性信息")
	@Log(title = "地块属性信息", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody Zone zone) {
		return toAjax(zoneService.insertZone(zone));
	}

	/**
	 * 修改地块属性信息
	 */
	@ApiOperation("修改地块属性信息")
	@Log(title = "地块属性信息", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody Zone zone) {
		return toAjax(zoneService.updateZone(zone));
	}

	/**
	 * 删除地块属性信息
	 */
	@ApiOperation("删除地块属性信息")
	@Log(title = "地块属性信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zoneIds}")
	public AjaxResult remove(@PathVariable Long[] zoneIds) {
		return toAjax(zoneService.deleteZoneByIds(zoneIds));
	}

	/**
	 * 获取地块主导产业信息详
	 */
	@ApiOperation("获取地块主导产业信息")
	@GetMapping(value = "/industry/{zoneId}")
	public AjaxResult selectIndustryById(@PathVariable("zoneId") Long zoneId)
	{
		return AjaxResult.success(zoneService.selectIndustryById(zoneId));
	}
	/**
	 * 新增地块主导产业信息
	 */
	@ApiOperation("新增地块主导产业信息")
	@Log(title = "新增地块主导产业信息", businessType = BusinessType.UPDATE)
	@PostMapping(value = "/addindustry")
	public AjaxResult insertIndustry(@RequestBody ZIndustry zIndustry)
	{
		return toAjax(zoneService.insertIndustry(zIndustry));
	}

	/**
	 * 修改地块主导产业信息
	 */
	@ApiOperation("修改地块主导产业信息")
	@Log(title = "修改地块主导产业信息", businessType = BusinessType.UPDATE)
	@PostMapping(value = "/editindustry")
	public AjaxResult updateIndustry(@RequestBody ZIndustry zIndustry)
	{
		return toAjax(zoneService.updateIndustry(zIndustry));
	}

	/**
	 * 查询地块属性信息列表
	 */
	@ApiOperation("查询地块属性范围信息列表")
	@GetMapping("/listBoundary")
	public TableDataInfo listBoundary(Zone zone) {
		startPage();
		List<Zone> list = zoneService.selectZoneListBoundary(zone);
		return getDataTable(list);
	}
}
